<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello Germmy Test Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .test-section {
            margin: 20px 0;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        button {
            background-color: #007bff;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            margin: 5px;
        }
        button:hover {
            background-color: #0056b3;
        }
        input[type="text"] {
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin: 5px;
            width: 200px;
        }
        .result {
            margin-top: 10px;
            padding: 10px;
            background-color: #f8f9fa;
            border-left: 4px solid #007bff;
            min-height: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Hello Germmy Controller 测试页面</h1>
        
        <div class="test-section">
            <h3>1. 简单GET请求测试</h3>
            <button onclick="testSimpleHello()">测试 GET /api/germmy/hello</button>
            <div id="result1" class="result"></div>
        </div>

        <div class="test-section">
            <h3>2. 带参数的GET请求测试</h3>
            <input type="text" id="nameInput" placeholder="输入姓名" value="张三">
            <button onclick="testHelloWithName()">测试 GET /api/germmy/hello/{name}</button>
            <div id="result2" class="result"></div>
        </div>

        <div class="test-section">
            <h3>3. POST请求测试</h3>
            <input type="text" id="messageInput" placeholder="输入消息" value="这是一条测试消息">
            <button onclick="testHelloWithMessage()">测试 POST /api/germmy/hello</button>
            <div id="result3" class="result"></div>
        </div>
    </div>

    <script>
        // 简单GET请求测试
        async function testSimpleHello() {
            try {
                const response = await fetch('/api/germmy/hello');
                const result = await response.text();
                document.getElementById('result1').innerHTML = `<strong>响应:</strong> ${result}`;
            } catch (error) {
                document.getElementById('result1').innerHTML = `<strong>错误:</strong> ${error.message}`;
            }
        }

        // 带参数的GET请求测试
        async function testHelloWithName() {
            try {
                const name = document.getElementById('nameInput').value || '张三';
                const response = await fetch(`/api/germmy/hello/${encodeURIComponent(name)}`);
                const result = await response.text();
                document.getElementById('result2').innerHTML = `<strong>响应:</strong> ${result}`;
            } catch (error) {
                document.getElementById('result2').innerHTML = `<strong>错误:</strong> ${error.message}`;
            }
        }

        // POST请求测试
        async function testHelloWithMessage() {
            try {
                const message = document.getElementById('messageInput').value || '这是一条测试消息';
                const response = await fetch('/api/germmy/hello', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify(message)
                });
                const result = await response.text();
                document.getElementById('result3').innerHTML = `<strong>响应:</strong> ${result}`;
            } catch (error) {
                document.getElementById('result3').innerHTML = `<strong>错误:</strong> ${error.message}`;
            }
        }
    </script>
</body>
</html>
